{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "569e4be5-a870-47fb-b0c8-cdad661c7311",
   "metadata": {},
   "source": [
    "##  nltk\n",
    "\n",
    "https://www.nltk.org/"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "09b32244-e620-4eaa-bcf8-9ebf463ea43c",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "global.index-url='https://pypi.mirrors.ustc.edu.cn/simple/'\n",
      "install.trusted-host='pypi.mirrors.ustc.edu.cn'\n"
     ]
    }
   ],
   "source": [
    "!pip config list"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "24c6d8c2-d36a-4eaa-92b1-848947c8e27b",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Name: unstructured\n",
      "Version: 0.16.5\n",
      "Summary: A library that prepares raw documents for downstream ML tasks.\n",
      "Home-page: https://github.com/Unstructured-IO/unstructured\n",
      "Author: Unstructured Technologies\n",
      "Author-email: devops@unstructuredai.io\n",
      "License: Apache-2.0\n",
      "Location: /opt/conda/lib/python3.11/site-packages\n",
      "Requires: backoff, beautifulsoup4, chardet, dataclasses-json, emoji, filetype, html5lib, langdetect, lxml, nltk, numpy, psutil, python-iso639, python-magic, python-oxmsg, rapidfuzz, requests, tqdm, typing-extensions, unstructured-client, wrapt\n",
      "Required-by: \n",
      "---\n",
      "Name: Markdown\n",
      "Version: 3.7\n",
      "Summary: Python implementation of John Gruber's Markdown.\n",
      "Home-page: \n",
      "Author: Manfred Stienstra, Yuri Takhteyev\n",
      "Author-email: Waylan limberg <python.markdown@gmail.com>\n",
      "License: BSD 3-Clause License\n",
      "\n",
      "Copyright 2007, 2008 The Python Markdown Project (v. 1.7 and later)  \n",
      "Copyright 2004, 2005, 2006 Yuri Takhteyev (v. 0.2-1.6b)  \n",
      "Copyright 2004 Manfred Stienstra (the original version)\n",
      "\n",
      "Redistribution and use in source and binary forms, with or without\n",
      "modification, are permitted provided that the following conditions are met:\n",
      "\n",
      "1. Redistributions of source code must retain the above copyright notice, this\n",
      "   list of conditions and the following disclaimer.\n",
      "\n",
      "2. Redistributions in binary form must reproduce the above copyright notice,\n",
      "   this list of conditions and the following disclaimer in the documentation\n",
      "   and/or other materials provided with the distribution.\n",
      "\n",
      "3. Neither the name of the copyright holder nor the names of its\n",
      "   contributors may be used to endorse or promote products derived from\n",
      "   this software without specific prior written permission.\n",
      "\n",
      "THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\n",
      "AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n",
      "IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n",
      "DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE\n",
      "FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n",
      "DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR\n",
      "SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\n",
      "CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,\n",
      "OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n",
      "OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n",
      "\n",
      "Location: /opt/conda/lib/python3.11/site-packages\n",
      "Requires: \n",
      "Required-by: \n"
     ]
    }
   ],
   "source": [
    "!pip show unstructured  markdown "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "d36534db-f3c7-4ce6-99f9-dab7855af62d",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Name: nltk\n",
      "Version: 3.9.1\n",
      "Summary: Natural Language Toolkit\n",
      "Home-page: https://www.nltk.org/\n",
      "Author: NLTK Team\n",
      "Author-email: nltk.team@gmail.com\n",
      "License: Apache License, Version 2.0\n",
      "Location: /opt/conda/lib/python3.11/site-packages\n",
      "Requires: click, joblib, regex, tqdm\n",
      "Required-by: unstructured\n"
     ]
    }
   ],
   "source": [
    "!pip show nltk"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "43873342-4a8f-42b6-ac6b-1fa3aacb19af",
   "metadata": {},
   "source": [
    "## Tokenize and tag some text"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "324a8a81-65e8-489b-87d4-4c5253cf35b7",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['At',\n",
       " 'eight',\n",
       " \"o'clock\",\n",
       " 'on',\n",
       " 'Thursday',\n",
       " 'morning',\n",
       " '...',\n",
       " 'Arthur',\n",
       " 'did',\n",
       " \"n't\",\n",
       " 'feel',\n",
       " 'very',\n",
       " 'good',\n",
       " '.']"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import nltk\n",
    "\n",
    "sentence = \"\"\"At eight o'clock on Thursday morning\n",
    "... Arthur didn't feel very good.\"\"\"\n",
    "\n",
    "tokens = nltk.word_tokenize(sentence)\n",
    "\n",
    "tokens"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "c522f92e-e659-4c7f-ab16-92c3a25f3f11",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[('At', 'IN'),\n",
       " ('eight', 'CD'),\n",
       " (\"o'clock\", 'NN'),\n",
       " ('on', 'IN'),\n",
       " ('Thursday', 'NNP'),\n",
       " ('morning', 'NN')]"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "tagged = nltk.pos_tag(tokens)\n",
    "tagged[0:6]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "40627a17-9f9e-40a3-a17e-0d6b5d63e61a",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
